package model_Ke;

import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.image.ImageObserver;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.text.AttributedCharacterIterator;
import java.util.List;
import java.util.Random;
import java.util.StringTokenizer;

import javax.swing.JFrame;
import javax.swing.JPanel;

import model_Ke.Point;

public abstract class IGraph {

	protected int[][] matrix;
	protected List<Point> numberPoints;
	protected MatrixWeight matrixWeight;

	protected IGraph(int[][] matrix, List<Point> numberPoints) {
		this.matrix = matrix;
		this.numberPoints = numberPoints;
	}

	public IGraph() {
	}

	protected IGraph(MatrixWeight matrixWeight, List<Point> numberPoints) {
		this.matrixWeight = matrixWeight;
		this.numberPoints = numberPoints;
	}

	// protected IGraph(int numberPoints){
	// this.matrix = new int[numberPoints][numberPoints];
	//
	// }
	protected IGraph(String file) {

	}

	private void run(String fileName) throws NumberFormatException, IOException {
		File file = new File(fileName);
		// try{
		BufferedReader br = new BufferedReader(new InputStreamReader(
				new FileInputStream(file)));

		int length = Integer.parseInt(br.readLine());
		for (int i = 0; i < length; i++) {
			String line = br.readLine();
			StringTokenizer token = new StringTokenizer(line);
			for (int j = 0; j < length; j++) {
				this.matrix[i][j] = Integer.parseInt(token.nextToken());
			}
		}
		// }catch(IOException e){
		// System.out.println(Error IO);
		// }
	}

	// public void inGraph(){
	// JFrame frame = new JFrame();
	// JPanel panel = new JPanel();
	// // frame.add(panel);
	// frame.getContentPane().add(panel);
	// Random random = new Random();
	//
	// for (int i = 0; i < this.size(); i++) {
	// Rectangle r = new Rectangle(random.nextInt(9),random.nextInt(9),1, 1);
	// panel.paintImmediately(r);
	// }
	// frame.repaint();
	// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	// frame.setVisible(true);
	// frame.setResizable(true);
	// }
	public int size() {
		return this.numberPoints.size();
	}

	public String toString() {
		String temp = "\n ";
		for (int i = 0; i < numberPoints.size(); i++) {
			temp = temp + " " + numberPoints.get(i);
		}
		for (int i = 0; i < matrix.length; i++) {
			temp = temp + "\n" + numberPoints.get(i);
			for (int j = 0; j < matrix.length; j++) {
				temp = temp + " " + matrix[i][j];
			}
		}
		// System.out.println(temp + "\n");
		return temp + "\n";
	}

	public abstract int deg(String u);

	public abstract int deg(int u);

	// public abstract int degOut(String u);
	public abstract int numberSumEdge();

	public abstract boolean addPoint(Point point);

	public abstract boolean addPoint(String name);

	public abstract void removePoint(Point point);

	public abstract void removePoint(String name);

	public abstract boolean isBipartite();

	public abstract boolean isConnection();

	public boolean isConnectionStrong() {
		return isConnection();
	}

	public abstract int countNumberConnection();

	public abstract boolean hasWay(String start, String end);

	public abstract boolean isEuler();

	public abstract String findEuler();

	public abstract boolean hasWayEuler();

	public abstract String findWayEuler();

	/**
	 * edge: canh
	 * 
	 * @param start
	 * @param end
	 */

	public abstract void addEdge(Point start, Point end);

	public abstract void addEdge(String start, String end);

	public abstract void removeEdge(Point start, Point end);

	public abstract void removeEdge(String start, String end);

	public abstract void removeEdge(int col, int row);

	public abstract int[][] getMatrix();

	public abstract int getNumberPoints();

	protected abstract void setSizeAddPoint();

	// public abstract boolean test

	/**
	 * Tree
	 */
	public abstract boolean isTree();

	public abstract int numberWay(int s, int e);

	public abstract List<Integer> mathEccentricity();

	public abstract FreeTree prim();

	/**
	 * Tim duong di ngan nhat
	 * 
	 * @return
	 */

	// public abstract
}
